feat: add Hermes Agent session collector (hardened, closes #167) - #168
Open
kouyichi wants to merge 2 commits into
Open
feat: add Hermes Agent session collector (hardened, closes #167)#168kouyichi wants to merge 2 commits into
kouyichi wants to merge 2 commits into
Conversation
Discover Hermes Agent sessions from tui_gateway.slash_worker processes (--session-key in already-scanned command lines) and read session metadata, token counters and the redacted transcript tail from ~/.hermes/state.db via an in-process read-only rusqlite connection (bundled SQLite). Addresses the security feedback that closed graykode#139: - No dynamic code generation: no Python, no string-built SQL, no shell interpolation anywhere; DB access is a readonly rusqlite connection with bound parameters only. - No temp files: everything is read in-process. - Follows the existing collector privacy model from the start: every DB-sourced string (title, cwd, chat tail, tool args) passes through sanitize_terminal_text -> redact_secrets -> truncation. - Fail-closed on symlinked/missing DBs; DB reads cached on the slow tick like OpenCodeCollector. Supports session discovery, token tracking (input/output/cache), status detection (Thinking/Executing/Waiting from transcript tail + CPU), context window % (model lookup table), child processes/ports, git status. Rate limits are N/A for Hermes. Closes graykode#167
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the hardened Hermes Agent collector proposed in #167. Closes #167.
What it does
Hermes Agent (Nous Research) sessions are discovered from the
tui_gateway.slash_worker --session-key <id>processes Hermes spawns per active session — parsed from the already-scannedSharedProcessDatacommand lines (token parsing only, no string building). Session metadata, token counters and the transcript tail are read directly from~/.hermes/state.db(orHERMES_HOME/state.db) through an in-process, read-onlyrusqliteconnection with bundled SQLite — nosqlite3CLI or Python required on any platform.Hide via
hidden_agents = ["hermes"]like any other agent.How it addresses the security feedback that closed #139
The previous attempt (PR #139) was closed over four concerns. This implementation addresses each:
SQLITE_OPEN_READ_ONLYconnection; process matching parses tokens from command lines already scanned by the shared snapshot.sanitize_terminal_text→redact_secrets→ truncation exactly like the OpenCode/Claude collectors. Tool results (role='tool') and internalsession_metarows never enter the chat tail.cargo clippy --all-targets -- -D warningspasses.DB rows and transcript tails are cached and refreshed only on the slow tick (~10s), matching the OpenCodeCollector pattern.
Verification
Tested live against running Hermes sessions (Linux):
abtop --once --jsonreports each active session with correct PID ↔ session matching, model, token counters, context %, status (Waiting vs Executing with open tool calls), project dir, prompt summary, tool timeline, and redacted chat tail. 10 new unit tests; full suite: 211 passed.Note:
rusqlite(bundled) is a new dependency — the alternative (sqlite3CLI like OpenCode) would silently fail on machines without the binary, which is why the in-process reader was chosen. Happy to switch if you prefer the CLI pattern.